package com.hanthink.web.controller.manhour;

import java.util.Date;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hanthink.common.annotation.Log;
import com.hanthink.common.core.controller.BaseController;
import com.hanthink.common.core.domain.AjaxResult;
import com.hanthink.common.enums.BusinessType;
import com.hanthink.system.domain.manhour.ProductionPlanFactAnaly;
import com.hanthink.system.service.manhour.IProductionPlanFactAnalyService;
import com.hanthink.common.utils.poi.ExcelUtil;
import com.hanthink.common.core.page.TableDataInfo;

/**
 * 生产计划和设备开停机差异分析Controller
 * 
 * @author hanthink
 * @date 2022-04-15
 */
@RestController
@RequestMapping("/manhour/ProductionPlanFactAnaly")
public class ProductionPlanFactAnalyController extends BaseController
{
    @Autowired
    private IProductionPlanFactAnalyService productionPlanFactAnalyService;

    /**
     * 查询生产计划和设备开停机差异分析列表
     */
    @PreAuthorize("@ss.hasPermi('manhour:ProductionPlanFactAnaly:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductionPlanFactAnaly productionPlanFactAnaly)
    {
        startPage();
        List<ProductionPlanFactAnaly> list = productionPlanFactAnalyService.selectProductionPlanFactAnalyList(productionPlanFactAnaly);
        return getDataTable(list);
    }

    /**
     * 导出生产计划和设备开停机差异分析列表
     */
    @PreAuthorize("@ss.hasPermi('manhour:ProductionPlanFactAnaly:export')")
    @Log(title = "生产计划和设备开停机差异分析", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProductionPlanFactAnaly productionPlanFactAnaly)
    {
        List<ProductionPlanFactAnaly> list = productionPlanFactAnalyService.selectProductionPlanFactAnalyList(productionPlanFactAnaly);
        ExcelUtil<ProductionPlanFactAnaly> util = new ExcelUtil<ProductionPlanFactAnaly>(ProductionPlanFactAnaly.class);
        return util.exportExcel(list, "ProductionPlanFactAnaly");
    }

    /**
     * 获取生产计划和设备开停机差异分析详细信息
     */
    @PreAuthorize("@ss.hasPermi('manhour:ProductionPlanFactAnaly:query')")
    @GetMapping(value = "/{workdate}")
    public AjaxResult getInfo(@PathVariable("workdate") Date workdate)
    {
        return AjaxResult.success(productionPlanFactAnalyService.selectProductionPlanFactAnalyById(workdate));
    }

    /**
     * 新增生产计划和设备开停机差异分析
     */
    @PreAuthorize("@ss.hasPermi('manhour:ProductionPlanFactAnaly:add')")
    @Log(title = "生产计划和设备开停机差异分析", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductionPlanFactAnaly productionPlanFactAnaly)
    {
        return toAjax(productionPlanFactAnalyService.insertProductionPlanFactAnaly(productionPlanFactAnaly));
    }

    /**
     * 修改生产计划和设备开停机差异分析
     */
    @PreAuthorize("@ss.hasPermi('manhour:ProductionPlanFactAnaly:edit')")
    @Log(title = "生产计划和设备开停机差异分析", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductionPlanFactAnaly productionPlanFactAnaly)
    {
        return toAjax(productionPlanFactAnalyService.updateProductionPlanFactAnaly(productionPlanFactAnaly));
    }

    /**
     * 删除生产计划和设备开停机差异分析
     */
    @PreAuthorize("@ss.hasPermi('manhour:ProductionPlanFactAnaly:remove')")
    @Log(title = "生产计划和设备开停机差异分析", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workdates}")
    public AjaxResult remove(@PathVariable Date[] workdates)
    {
        return toAjax(productionPlanFactAnalyService.deleteProductionPlanFactAnalyByIds(workdates));
    }
}
